package org.qiyu.live.gift.provider.rpc;

import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboService;
import org.qiyu.live.common.interfaces.utils.ConvertBeanUtils;
import org.qiyu.live.gift.dto.RedPacketConfigReqDTO;
import org.qiyu.live.gift.dto.RedPacketConfigRespDTO;
import org.qiyu.live.gift.dto.RedPacketReceiveDTO;
import org.qiyu.live.gift.interfaces.IRedPacketConfigRPC;
import org.qiyu.live.gift.provider.dao.po.RedPacketConfigPO;
import org.qiyu.live.gift.provider.service.IRedPacketConfigService;

/**
 * @Program: qiyu-live-app
 *
 * @Description:
 *
 * @Author: tangfh
 *
 * @Create: 2024-08-12 16:58
 */
@DubboService
public class RedPacketConfigRPCImpl implements IRedPacketConfigRPC {

    @Resource
    private IRedPacketConfigService redPacketConfigService;

    @Override
    public RedPacketConfigRespDTO queryByAuthorId(Long authorId) {
        return ConvertBeanUtils.convert(redPacketConfigService.queryByAuthorId(authorId), RedPacketConfigRespDTO.class);
    }

    @Override
    public boolean addOne(RedPacketConfigRespDTO redPacketConfigRespDTO) {
        return redPacketConfigService.addOne(ConvertBeanUtils.convert(redPacketConfigRespDTO, RedPacketConfigPO.class));
    }

    @Override
    public boolean updateById(RedPacketConfigRespDTO redPacketConfigRespDTO) {
        return redPacketConfigService.updateById(ConvertBeanUtils.convert(redPacketConfigRespDTO, RedPacketConfigPO.class));
    }

    @Override
    public boolean prepareRedPacket(Long authorId) {
        return redPacketConfigService.prepareRedPacket(authorId);
    }

    @Override
    public RedPacketReceiveDTO receiveRedPacket(RedPacketConfigReqDTO reqDTO) {
        return redPacketConfigService.receiveRedPacket(reqDTO);
    }

    @Override
    public boolean startRedPacket(RedPacketConfigReqDTO reqDTO) {
        return redPacketConfigService.startRedPacket(reqDTO);
    }
}
